package com.queue;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

public class TestQueue {

	  public static void main(String[] args) {
		  TestRun run = new TestRun();
		  run.add();
		  run.start();
	}

}

class TestRun extends Thread{
private LinkedBlockingQueue<Integer> queue = new LinkedBlockingQueue<Integer>();
	  @Override
	public void run() {
		while(true){
			try {
				Integer poll = queue.poll(1, TimeUnit.SECONDS);
				System.out.println("queue.poll="+poll);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	  
	public void add(){
		queue.add(1);
		queue.add(2);
		queue.add(3);
	}
}

